module material.material;

import material.texture;
import render.render;
import utils.color;
import utils.vector3;

public class Material {
    abstract public RGBColor value(inout RenderContext context, Vector3f light_vector);
    abstract public Texture getTexture(uint index);
    abstract public void setTexture(uint index, Texture tex);
}

public class SimpleMaterial : Material {
    private Texture mTexture;

    this() {
        //no-op default texture
        mTexture = new Texture();
        mTexture.color = RGBColor(1.0f);
    }
    this (Texture tex) {
        mTexture = tex;
    }

    public void setTexture(uint index, Texture tex) {
        if (index == 0)
            mTexture = tex;
    }

    public Texture getTexture(uint index) {
        if (index == 0)
            return mTexture;
        else
            return null;
    }

    public RGBColor value(inout RenderContext context, Vector3f light_vector) {
        return mTexture.getColor(context);
    }
}
